from pydoc import describe

from const import cmd_proto_path


def genCmdProtofile(cmdprotos):
    fileContent = ""
    fileContent += (
    'syntax = "proto3";'
    '\n'
    'package msg;'
    '\n'
    'option go_package="/client";'
    '\n'
    '// 这里我们注册 protobuf 消息命令)\n'
    '\n'
    'enum ClientCmd {'
    '\n'
    '  Cmd_Main_Code = 0;\n'
    '\n'
    )
        # SubCmd_Main_Code = 0;
    for item in cmdprotos:
        fieds=item.split("_")
        code=fieds[0]
        name=fieds[1]
        desc=fieds[2]
        fileContent += '  Cmd'
        fileContent +=name
        fileContent += '= '
        fileContent += code
        fileContent += ';//'
        fileContent += desc

    fileContent += ("\n}")

    fo = open(cmd_proto_path, "wb")
    fo.write(fileContent.encode('utf-8'))
    fo.close()

